package com.lin.blog.controller;

import com.lin.blog.repository.ArticleCategoryTagsRepository;
import com.lin.blog.service.IArticleCategoryTagsService;
import com.lin.blog.service.IElasticSearchService;
import com.lin.blog.vo.ArticleCategoryTagsVO;
import com.lin.constant.ResultCode;
import com.lin.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: blog
 * @description: elasticsearch控制器
 * @author: Lin
 * @create: 2020-04-07 18:40
 **/
@Api(tags = "ElasticSearch接口")
@RestController
@RequestMapping("/elasticsearch")
public class ElasticSearchController {

    //https://www.cnblogs.com/sddai/p/11061412.html elasticsearch 语法查询

    @Autowired
    private IElasticSearchService elasticSearchService;

    /**
     * 导入数据
     * @return
     */
    @ApiOperation("导入数据")
    @PostMapping("/import_data")
    public Result importArticleData(){
        return elasticSearchService.importArticleData();
    }

    /**
     * 创建索引
     * @return
     */
    @ApiOperation("删除索引")
    @PostMapping("/delete_index")
    public Result deleteIndex(){
        return elasticSearchService.deleteIndex();
    }

    /**
     * 创建索引
     * @return
     */
    @ApiOperation("创建索引")
    @PostMapping("/create_index")
    public Result createIndex(){
        return elasticSearchService.createIndex();
    }



}
